package com.example.demo.controller;

import com.example.demo.utils.TtsUtil;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.*;
import java.lang.reflect.Field;

@RestController
public class MyController {


    @RequestMapping("/create")
    public String create() {
        TtsUtil.create("text", "测试一段话");
        return "ok";
    }

    @RequestMapping("/createTxt")
    public String createTxt() {
        File file = new File("testCreate.txt");
        try (OutputStream outputStream = new FileOutputStream(file)) {
            outputStream.write("哈哈".getBytes());
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return "testCreate.txt";
    }

    @RequestMapping("/call")
    public String call() {
        TtsUtil.call("text");
        return "ok";
    }
}
